package com.test.dababy.dababy_05_process;

import static com.test.dababy.dababy_00_utils.DababyConfigs.Debug;
import static com.test.dababy.dababy_00_utils.DababyUtil.startLoading;
import static com.test.dababy.dababy_00_utils.DababyUtil.stopLoading;
import static com.test.dababy.dababy_00_utils.DababyConfigs.PermissionCode_Camera;
import static com.test.dababy.dababy_00_utils.DababyConfigs.Process_Step_Ocr;
import static com.test.dababy.dababy_00_utils.DababyConfigs.Process_Step_Personal;
import static com.test.dababy.dababy_00_utils.DababyConfigs.Process_Step_Sefie;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.PickVisualMediaRequest;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.test.dababy.R;
import com.test.dababy.dababy_00_utils.Kind_dababyTip_dababyDialog;
import com.test.dababy.dababy_06_loan_apply.LoanApplyActivity;
import com.test.dababy.dababy_05_process.widget.BaseProc_dababyessWid_dababygetManager;
import com.test.dababy.dababy_06_loan_apply.LoanApplyActivity_OldUser;
import com.test.dababy.dababy_10_vip.Pers_dababyonalIn_dababyfo;
import com.test.dababy.dababy_00_customer_service.Customer_dababyServiceDialog;
import com.test.dababy.dababy_00_http.OkHttpUtil;
import com.test.dababy.dababy_00_utils.image_dababy.Image_dababyConvert;
import com.test.dababy.dababy_05_process.widget.BindAcco_dababyuntViewM_dababyanager_Fr;
import com.test.dababy.dababy_05_process.widget.DateS_dababyelectVie_dababywManager;
import com.test.dababy.dababy_05_process.widget.Face_dababyViewM_dababyanager;
import com.test.dababy.dababy_05_process.widget.Ge_dababynderSe_dababylectViewManager;
import com.test.dababy.dababy_05_process.widget.Input_dababyViewMan_dababyager;
import com.test.dababy.dababy_05_process.widget.OcrVie_dababywMana_dababyger;
import com.test.dababy.dababy_05_process.widget.Sele_dababyctViewMana;
import com.test.dababy.dababy_00_utils.DababyConfigs;
import com.test.dababy.dababy_00_utils.DababyUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;

public class Pro_dababycessAct_dababyivity extends AppCompatActivity implements EasyPermissions.RationaleCallbacks,EasyPermissions.PermissionCallbacks{


    private boolean w7qt=false;
    private boolean a9dO=true;
    private String yszx="";
    private int tI4P=235;
    private String dVxp="";
    private float cr56=0.17708248f;
    private boolean ipWz=false;
    private char vj16=',';
    private float x4Wd=0.8196252f;
    private String aL1x="";

    public void hkf5m(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getaL1x())) setdVxp(getYszx()+getX4Wd()+getVj16()+gettI4P());
                else setdVxp(String.valueOf(isA9dO())+isW7qt());

            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void setW7qt(boolean w7qt) {
        this.w7qt = w7qt;
    }

    public void setA9dO(boolean a9dO) {
        this.a9dO = a9dO;
    }

    public void setYszx(String yszx) {
        this.yszx = yszx;
    }

    public void settI4P(int tI4P) {
        this.tI4P = tI4P;
    }

    public void setdVxp(String dVxp) {
        this.dVxp = dVxp;
    }

    public void setCr56(float cr56) {
        this.cr56 = cr56;
    }

    public void setIpWz(boolean ipWz) {
        this.ipWz = ipWz;
    }

    public void setVj16(char vj16) {
        this.vj16 = vj16;
    }

    public void setX4Wd(float x4Wd) {
        this.x4Wd = x4Wd;
    }

    public void setaL1x(String aL1x) {
        this.aL1x = aL1x;
    }

    public boolean isW7qt() {
        return w7qt;
    }

    public boolean isA9dO() {
        return a9dO;
    }

    public String getYszx() {
        return yszx;
    }

    public int gettI4P() {
        return tI4P;
    }

    public String getdVxp() {
        return dVxp;
    }

    public float getCr56() {
        return cr56;
    }

    public boolean isIpWz() {
        return ipWz;
    }

    public char getVj16() {
        return vj16;
    }

    public float getX4Wd() {
        return x4Wd;
    }

    public String getaL1x() {
        return aL1x;
    }

    private TextView title1Tv,title2Tv;
    private View topView;
    private LinearLayout topGroupLayout,processGroupLayout;
    private Button nextBtn;

    private Proce_dababyssInf_dababyo_Step step_dababy;

    private final ArrayList<BaseProc_dababyessWid_dababygetManager> processWidgetManagers_dababy = new ArrayList<>();

    private BindAcco_dababyuntViewM_dababyanager_Fr bindAccountViewManager_dababy;//法语区绑卡组件
    private OcrVie_dababywMana_dababyger ocrViewManager_dababy;//Ocr组件
    private Face_dababyViewM_dababyanager faceViewManager_dababy;//Face组件

    private String path_dababy;

    private Runnable nextBtnRunnable_dababy;

    private String currentStepName = "";

    private final String[] userNames = new String[]{"","",""};

    private static String page_dababy = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dababy_process);
        if (!Debug) getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);

        currentStepName = Pro_dababycessIn_dababyfo.getInstance_dababy().getStepName_dababy(0);

        if (!TextUtils.isEmpty(currentStepName)) page_dababy = currentStepName.toUpperCase();
        else page_dababy = getClass().getSimpleName().toUpperCase();

        findViewById(R.id.adp2_ib_back).setOnClickListener(v -> onBackPressed());
        findViewById(R.id.adp2_ib_cs).setOnClickListener(v -> new Customer_dababyServiceDialog(this).show());

        title1Tv = findViewById(R.id.adp2_tv_title_1);
        title2Tv = findViewById(R.id.adp2_tv_title_2);
        topView = findViewById(R.id.adp2_view_top);
        topGroupLayout = findViewById(R.id.adp2_layout_top_group);
        processGroupLayout = findViewById(R.id.adp2_layout_process_group);
        nextBtn = findViewById(R.id.adp2_btn_next);

        step_dababy = Pro_dababycessIn_dababyfo.getInstance_dababy().getStep_dababy(0);
        path_dababy = step_dababy == null ? "": step_dababy.getApiUrl_dababy();

        //next
        nextBtn.setOnClickListener(v -> {
            OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"SAVE_CLICK","");
            if (step_dababy == null||TextUtils.isEmpty(path_dababy)) {
                onBackPressed();
                return;
            }
            if (nextBtnRunnable_dababy !=null) nextBtnRunnable_dababy.run();
        });

        initProcessStep();

    }

    //初始化流程步骤框架
    @SuppressLint("SetTextI18n")
    private void initProcessStep(){

        //Ocr和人脸流程直接添加
        if (currentStepName.equalsIgnoreCase(Process_Step_Ocr)){
            topView.setVisibility(View.GONE);
            initOcrProcess_dababy(processGroupLayout);
            title1Tv.setText(getString(R.string.process_ocr_title));
            return;
        }else if (currentStepName.equalsIgnoreCase(Process_Step_Sefie)){
            topView.setVisibility(View.GONE);
            initFaceProcess_dababy(processGroupLayout);
            title1Tv.setText(getString(R.string.process_face_title));
//            nextBtn.setText(getString(R.string.face_btn));
            return;
        }

        ArrayList<String> allSteps = Pro_dababycessIn_dababyfo.getInstance_dababy().getAllSteps_dababy();
        ArrayList<String> steps = Pro_dababycessIn_dababyfo.getInstance_dababy().getSteps_dababy();

        if (step_dababy!=null){
            String num = (allSteps.indexOf(currentStepName)+1) + ".";
            title2Tv.setText(num+step_dababy.getTitle_dababy());
        }

        //初始化顶部流程显示
        for (String step:allSteps){

            View view = View.inflate(this,R.layout.view_dababy_process_top_step,null);
            View bg = view.findViewById(R.id.vptt_bg);
            View pointerView = view.findViewById(R.id.vptt_iv_pointer);

            //当前流程
            if (steps.indexOf(step)==0){
                bg.setBackgroundResource(R.drawable.bg_main_rc);
                pointerView.setVisibility(View.VISIBLE);
            }
            //已完成流程
            else if (!steps.contains(step)){
                bg.setBackgroundResource(R.drawable.bg_main_rc);
                pointerView.setVisibility(View.INVISIBLE);
            }
            //后续流程
            else {
                bg.setBackgroundResource(R.drawable.bg_white_round_corner);
                pointerView.setVisibility(View.INVISIBLE);
            }

            view.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT,1));
            topGroupLayout.addView(view);

        }

        hkf5m();

        for (int i=0;i<allSteps.size();i++){

            String stepName = allSteps.get(i);

            if (!steps.contains(stepName)){//已完成流程
                //添加已完成流程展示
                View item = View.inflate(this,R.layout.view_dababy_process_item_finish,null);
                TextView stepNameTv = item.findViewById(R.id.vdpif_tv_step_name);
                stepNameTv.setText(Pro_dababycessIn_dababyfo.getInstance_dababy().getStepTitle_dababy(i));
                processGroupLayout.addView(item);
            }else if (stepName.equalsIgnoreCase(currentStepName)){//当前流程
                //添加当前流程展示
                View item = View.inflate(this,R.layout.view_dababy_process_item_current,null);
                TextView stepNameTv = item.findViewById(R.id.vpdic_tv_step_name);
                stepNameTv.setText(Pro_dababycessIn_dababyfo.getInstance_dababy().getStepTitle_dababy(i));
                initProcessItems_dababy(item.findViewById(R.id.vpdic_layout_group));
                processGroupLayout.addView(item);
            }else {//后续流程
                //添加后续流程展示
                View item = View.inflate(this,R.layout.view_dababy_process_item,null);
                TextView stepNameTv = item.findViewById(R.id.vdpi_tv_step_name);
                stepNameTv.setText(Pro_dababycessIn_dababyfo.getInstance_dababy().getStepTitle_dababy(i));
                processGroupLayout.addView(item);
            }

        }

    }

//-----------------------Old-------------------------------
    /**
     * 初始化流程
     */
    @SuppressLint("SetTextI18n")
    private void initProcessItems_dababy(LinearLayout groupLayout){
        if (step_dababy == null) {
            onBackPressed();
            return;
        }

        //根据流程类型分别处理
        switch (currentStepName){
            case DababyConfigs.Process_Step_Contact://联系人流程
                initContactProcess_dababy(groupLayout);
                break;
            case DababyConfigs.Process_Step_Account://绑卡流程
                if (DababyUtil.isFrench_dababy()){//法语区绑卡流程
                    initBindAccountProcess_Fr_dababy(groupLayout);
                    startLoading(this,"");
                    OkHttpUtil.getInstance_dababy().fetchWalletAccountList_fr(this::onFetchFrAccountListResponse_dababy);
                    break;
                }
            default://普通流程
                initNormalProcess_dababy(groupLayout);
        }

    }

    /**
     * 普通流程
     */
    private void initNormalProcess_dababy(LinearLayout groupLayout){

        View group2View = View.inflate(this,R.layout.view_dababy_item_bg_dababy_group,null);
        LinearLayout group2Layout = group2View.findViewById(R.id.vibg_layout_group);

        for (int i = 0; i< step_dababy.getDataListSize_dababy(); i++){
            Proces_dababysIn_dababyfo_Data data = step_dababy.getProcessData_dababy(i);
            if (data==null) continue;
            addInputView_dababy(data,null,group2Layout);
        }

        //数据上报处理
        nextBtnRunnable_dababy = () -> {

            for (BaseProc_dababyessWid_dababygetManager processWidgetManager: processWidgetManagers_dababy){
                if (!processWidgetManager.checkI_dababynput()){
                    processWidgetManager.inputEmptyTip();
                    new Kind_dababyTip_dababyDialog(this, getString(R.string.process_tips_not_filled_completely),
                            "",null,
                            getString(R.string.ok), null).show();
                    return;
                }
            }

            TreeMap<String,String> dataMap = new TreeMap<>();

            for (BaseProc_dababyessWid_dababygetManager baseInfoInputViewManager: processWidgetManagers_dababy){

                Proces_dababysIn_dababyfo_Data data = baseInfoInputViewManager.getDa_dababyta();
                if (data!=null) dataMap.put(data.getParamName_dababy(),baseInfoInputViewManager.getInp_dababyut().trim());
            }
            startLoading(this,"");
            OkHttpUtil.getInstance_dababy().uploadUserPrcsInfo(
                    path_dababy,dataMap,
                    () -> {
                        for (String k:dataMap.keySet()){
                            String v = dataMap.get(k);
                            extractPersonalInfo(k,v);
                        }
                        onSubmitInfoResponse_dababy();
                    });

        };

        groupLayout.addView(group2View);
    }

    /**
     * 联系人流程
     */
    @SuppressLint("InflateParams")
    private void initContactProcess_dababy(LinearLayout groupLayout){

        View group2View = View.inflate(this,R.layout.view_dababy_item_bg_dababy_group,null);
        LinearLayout group2Layout = group2View.findViewById(R.id.vibg_layout_group);

        for (int i = 0; i< step_dababy.getExtDataListSize_dababy(); i++){
            Proces_dababysIn_dababyfo_Data data = step_dababy.getExtProcessData_dababy(i);
            if (data==null) continue;
            addInputView_dababy(data,null,group2Layout);
        }

        if (step_dababy.getItemCount_dababy()<=0) return;

        //添加一组联系人输入控件
        if (step_dababy.getExtDataListSize_dababy()>0) groupLayout.addView(group2View);
        //重新初始化一组新的联系人输入控件
        group2View = View.inflate(this,R.layout.view_dababy_item_bg_dababy_group,null);
        group2Layout = group2View.findViewById(R.id.vibg_layout_group);

        int count = 0;

        while (count< step_dababy.getItemCount_dababy()){//联系人数量
            for (int i = 0; i< step_dababy.getDataListSize_dababy(); i++){
                Proces_dababysIn_dababyfo_Data data = step_dababy.getProcessData_dababy(i);
                if (data==null) continue;
                addInputView_dababy(data, step_dababy.getRelationShips_dababy(count),group2Layout);
            }

            //添加一组联系人输入控件
            groupLayout.addView(group2View);

            if (++count < step_dababy.getItemCount_dababy()){
                //重新初始化一组新的联系人输入控件
                group2View = View.inflate(this,R.layout.view_dababy_item_bg_dababy_group,null);
                group2Layout = group2View.findViewById(R.id.vibg_layout_group);
            }else break;
        }

        //数据上报处理
        nextBtnRunnable_dababy = () -> {

            TreeMap<String,String> dataMap = new TreeMap<>();

            ArrayList<String> relashipList = new ArrayList<>();
            ArrayList<String> nameList = new ArrayList<>();
            ArrayList<String> phoneList = new ArrayList<>();

            for (BaseProc_dababyessWid_dababygetManager baseInfoInputViewManager: processWidgetManagers_dababy){

                Proces_dababysIn_dababyfo_Data data = baseInfoInputViewManager.getDa_dababyta();
                if (data==null) continue;
                switch (data.getAction_dababy()){

                    case DababyConfigs.Data_Act_dababyion_Contact_Relation:
                        relashipList.add(((Sele_dababyctViewMana)baseInfoInputViewManager).getTe_dababyxtInput());
                        break;

                    case DababyConfigs.Data_Action_Conta_dababyct_Name:
                        nameList.add(baseInfoInputViewManager.getInp_dababyut());
                        break;

                    case DababyConfigs.Data_Action_Conta_dababyct_Phone:
                        phoneList.add(baseInfoInputViewManager.getInp_dababyut());
                        break;

                    default: dataMap.put(data.getParamName_dababy(),baseInfoInputViewManager.getInp_dababyut().trim());
                }

            }

            //添加联系人信息
            if (!TextUtils.isEmpty(step_dababy.getContactParamName_dababy())){
                JSONArray jsonArray = new JSONArray();
                for (int i=0;i<relashipList.size();i++){
                    JSONObject jsonObject = new JSONObject();
                    try {
                        jsonObject.put("relation",relashipList.get(i).trim());
                        if (i<nameList.size()) jsonObject.put("fullName",nameList.get(i).trim());
                        if (i<phoneList.size()) jsonObject.put("mobile",phoneList.get(i).trim());
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    jsonArray.put(jsonObject);
                }
                dataMap.put(step_dababy.getContactParamName_dababy(),jsonArray.toString());
            }

            startLoading(this,"");
            OkHttpUtil.getInstance_dababy().uploadUserPrcsInfo(path_dababy,dataMap,this::onSubmitInfoResponse_dababy);

        };

    }

    /**
     * 法语区绑卡流程
     */
    private void initBindAccountProcess_Fr_dababy(LinearLayout groupLayout){

        View group2View = View.inflate(this,R.layout.view_dababy_item_bg_dababy_group,null);
        LinearLayout group2Layout = group2View.findViewById(R.id.vibg_layout_group);

        @SuppressLint("InflateParams") View bindAccountView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_bindaccount_fr,null);
        bindAccountViewManager_dababy = new BindAcco_dababyuntViewM_dababyanager_Fr(bindAccountView,null, page_dababy);
        group2Layout.addView(bindAccountView);

        nextBtn.setBackgroundResource(R.drawable.bg_btn_gray);

        Acc_dababyountLi_dababyst_Fr.getInstance_dababy().setParseRunnable_dababy(() -> {
            if (Acc_dababyountLi_dababyst_Fr.getInstance_dababy().getBankAccountList_dababy().isEmpty())
                nextBtn.setBackgroundResource(R.drawable.bg_btn_gray);
            else
                nextBtn.setBackgroundResource(R.drawable.bg_btn_light);
        });

        nextBtnRunnable_dababy = () -> {

            if (bindAccountView == null) {
                onBackPressed();
                return;
            }

            if (Acc_dababyountLi_dababyst_Fr.getInstance_dababy().getBankAccountList_dababy().isEmpty()){//无绑卡提示
                new Kind_dababyTip_dababyDialog(this, getString(R.string.bind_card_tips_no_card),
                        "",null,
                        getString(R.string.ok), null).show();
                return;
            }

            if (Acc_dababyountLi_dababyst_Fr.getInstance_dababy().getBankAccountList_dababy().size()<2){
                new BindA_dababycc_dababyountTipDialog_Fr(this,() -> {
                    //提交绑卡
                    new Subm_dababyitAccount_dababyDialog_Fr(this, this::onSubmitInfoResponse_dababy
                            , page_dababy).show();
                }).show();
                return;
            }

            new Subm_dababyitAccount_dababyDialog_Fr(this,() ->{
                //提交绑卡
                startLoading(this,"");
                OkHttpUtil.getInstance_dababy().requestUsPrcs(this::onProcessInfoResponse_dababy);
            }
            , page_dababy).show();

        };


        groupLayout.addView(group2View);
    }

    /**
     * 人脸流程
     */
    private void initFaceProcess_dababy(LinearLayout groupLayout){

        @SuppressLint("InflateParams") View faceView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_face,null);
        faceViewManager_dababy = new Face_dababyViewM_dababyanager(
                faceView,null, page_dababy,
                this::onProcessInfoResponse_dababy,
                () -> {if (faceViewManager_dababy !=null) faceViewManager_dababy.onPhotoUplo_dababyadRespo_dababynse();}
        );
        groupLayout.addView(faceView);

        nextBtnRunnable_dababy = () -> {
            if (faceView==null || faceViewManager_dababy ==null) {
                onBackPressed();
                return;
            }
            faceViewManager_dababy.nextCl_dababyick(path_dababy);
        };

    }

    /**
     * Ocr流程
     */
    private void initOcrProcess_dababy(LinearLayout groupLayout){

        @SuppressLint("InflateParams") View ocrView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_ocr,null);
        ocrViewManager_dababy = new OcrVie_dababywMana_dababyger(
                ocrView,null, page_dababy,
                this::onProcessInfoResponse_dababy,
                () -> {if (ocrViewManager_dababy !=null) ocrViewManager_dababy.onPhot_dababyoUploadRe_dababysponse();}
        );
        groupLayout.addView(ocrView);

        ActivityResultLauncher<PickVisualMediaRequest> pickMedia_dababy = registerForActivityResult(new ActivityResultContracts.PickVisualMedia(), uri -> {
            if (uri != null && ocrViewManager_dababy != null) {
                ocrViewManager_dababy.pho_dababytoUri = uri;
                ocrViewManager_dababy.imgPa_dababyth = Image_dababyConvert.get_dababyBitmap_dababyFileP_dababyathFromURI(this, ocrViewManager_dababy.pho_dababytoUri);
                ocrViewManager_dababy.onPh_dababyot_dababyoGet();
            }
        });

        ocrViewManager_dababy.set_dababyPick_dababyMe(pickMedia_dababy);

        nextBtnRunnable_dababy = () -> {
            if (ocrView == null || ocrViewManager_dababy ==null) {
                onBackPressed();
                return;
            }
            ocrViewManager_dababy.nextC_dababylick(path_dababy);
        };

    }

    /**
     * 添加信息输入控件
     * @param data 控件参数
     * @param relationships 联系人关系选项，可为空
     * @param groupLayout 控件容器
     */
    @SuppressLint("InflateParams")
    private void addInputView_dababy(Proces_dababysIn_dababyfo_Data data, ArrayList<String> relationships, LinearLayout groupLayout){

        View inputView = null;

        switch (data.getAction_dababy()){

            case DababyConfigs.Dat_dababya_Action_Select:
                inputView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_select,null);
                Sele_dababyctViewMana selectViewManager = new Sele_dababyctViewMana(inputView,data, page_dababy);
                processWidgetManagers_dababy.add(selectViewManager);
                break;

            case DababyConfigs.Data_Action_DateP_dababyick:
                inputView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_dateselect,null);
                DateS_dababyelectVie_dababywManager datePickWidgetsManager = new DateS_dababyelectVie_dababywManager(inputView,data, page_dababy);
                processWidgetManagers_dababy.add(datePickWidgetsManager);
                break;

            case DababyConfigs.Data_Act_dababyion_Contact_Relation://联系人-关系
                if (relationships!=null) data.setRelationships_dababy(relationships);
                inputView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_select,null);
                Sele_dababyctViewMana contactSelectViewManager = new Sele_dababyctViewMana(inputView,data, page_dababy);
                processWidgetManagers_dababy.add(contactSelectViewManager);
                break;

            case DababyConfigs.Data_Act_dababyion_GenderPick:
                inputView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_genderselect,null);
                Ge_dababynderSe_dababylectViewManager genderSelectViewManager = new Ge_dababynderSe_dababylectViewManager(inputView,data, page_dababy);
                processWidgetManagers_dababy.add(genderSelectViewManager);
                break;

            case DababyConfigs.Data_Action_In_dababyput:
            case DababyConfigs.Data_Action_Conta_dababyct_Name://联系人-名字
            case DababyConfigs.Data_Action_Conta_dababyct_Phone://联系人-电话
            default:
                inputView = LayoutInflater.from(this).inflate(R.layout.item_dababy_process_input,null);
                Input_dababyViewMan_dababyager inputWidgetsManager = new Input_dababyViewMan_dababyager(inputView,data, page_dababy);
                processWidgetManagers_dababy.add(inputWidgetsManager);
                break;
        }

        if (inputView!=null) groupLayout.addView(inputView);
    }



//-------------------------------------------权限处理-----------------------------------------------------------
    @Override
    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PermissionCode_Camera){
            if (faceViewManager_dababy != null) faceViewManager_dababy.onCameraPer_dababymission_dababyAgree();
            else if (ocrViewManager_dababy !=null) ocrViewManager_dababy.onCam_dababyeraPermissio_dababynAgree();
        }
    }

    @Override
    public void onRationaleDenied(int requestCode) {}

    @Override
    public void onRationaleAccepted(int requestCode) {
        if (requestCode == PermissionCode_Camera)
            EasyPermissions.requestPermissions(this,
                    getString(R.string.launch_permissions_camera_dababy),
                    PermissionCode_Camera,
                    Manifest.permission.CAMERA);
    }

    @Override
    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
        if (requestCode == PermissionCode_Camera) {
            if (EasyPermissions.somePermissionPermanentlyDenied(this, perms))
                new AppSettingsDialog.Builder(this).build().show();
        }
    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (ocrViewManager_dababy !=null && requestCode== OcrVie_dababywMana_dababyger.Flag_StartCam_dababyera){
            ocrViewManager_dababy.onPh_dababyot_dababyoGet();
        }
    }

    //-------------------------------------------响应-----------------------------------------------------------

    //信息上报成功响应
    public void onSubmitInfoResponse_dababy(){
        OkHttpUtil.getInstance_dababy().requestUsPrcs(this::onProcessInfoResponse_dababy);
    }

    public void onFetchFrAccountListResponse_dababy(){
        stopLoading();
        if (bindAccountViewManager_dababy !=null) bindAccountViewManager_dababy.refreshAcc_dababyountList();
    }

    public void onProcessInfoResponse_dababy(){
        stopLoading();
        //无流程：跳转到申请页
        if (Pro_dababycessIn_dababyfo.getInstance_dababy().getSteps_dababy().isEmpty())
            toApply();
            //有流程：跳转到流程页
        else startActivity(new Intent(this, Pro_dababycessAct_dababyivity.class));

        finish();
    }


    //----------------------------------------提取基本信息中的全名----------------------------
    private void extractPersonalInfo(String key,String value){
        if (!currentStepName.equalsIgnoreCase(Process_Step_Personal)) return;
        switch (key){
            case "firstName":
                userNames[0] = value.trim();
                break;
            case "middleName":
                userNames[1] = value.trim();
                break;
            case "lastName":
                userNames[2] = value.trim();
                break;

        }

        if (!TextUtils.isEmpty(userNames[0]) && !TextUtils.isEmpty(userNames[2])){
            Pers_dababyonalIn_dababyfo.getInstance().setFullName(
                    userNames[0]+" "+(TextUtils.isEmpty(userNames[1]) ? "":userNames[1]+" ")+userNames[2]
            );
            Pers_dababyonalIn_dababyfo.getInstance().uploadUserInfo(null);
        }

    }

    @Override
    protected void onResume() {
        super.onResume();
        OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"START","");
    }

    @Override
    protected void onPause() {
        super.onPause();
        OkHttpUtil.getInstance_dababy().uploadEventPoint(page_dababy,"END","");
    }

    //跳转到申请页
    private void toApply(){
        if (Pro_dababycessIn_dababyfo.getInstance_dababy().isNewUser_dababy())
            startActivity(new Intent(this, LoanApplyActivity.class));
        else startActivity(new Intent(this, LoanApplyActivity_OldUser.class));

    }

}